package com.example.demo.service.Impl;

import com.example.demo.mapper.DepartmentMapper;
import com.example.demo.model.Department;
import com.example.demo.service.IdepartmentService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@AllArgsConstructor
public class DepartmentServiceImpl implements IdepartmentService {

//    @Autowired
//    private DepartmentMapper departmentMapper;
    private final DepartmentMapper departmentMapper;

    @Transactional
    @Override
    public void addDepartment(Department department) {
        departmentMapper.addDepartment(department);
    }

    @Override
    public List<Department> getAllDepart() {
        return departmentMapper.getAllDepart();
    }

    @Transactional
    @Override
    public void deleteDepartById(Long id) {
        departmentMapper.deleteDepartById(id);
    }

}
